/*
 *  atBudget Personal Finance Management application
 *
 *  Copyright 2011, Ilia Frenkel <frenkel.ilia@gmail.com>
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
	Accounts list. This list is used in accounts management dialogue.
 */
Ext.define('ATB.view.account.List' ,{
    extend: 'Ext.grid.Panel',
    alias : 'widget.accountlist',
	store : 'Accounts',
    title : 'Accounts',
	hideHeaders: true,
	viewConfig: {
		emptyText: '<p style="text-align:center;color:#999999;font-weight: '+
			'bold;font-size:120%;margin-top:2em">No accounts found.</p>',
		singleSelect: true,
		allowDeselect: false,
		stripeRows: true
	},
	bodyCls: 'atb-accountlist',

    initComponent: function() {
        this.columns = [
            {header: 'Name', dataIndex: 'name', flex: 1, renderer: renderAccountRow}
        ];
		
        this.callParent(arguments);
    }
});

/*
	Custom renderer for a row in accounts list.
*/
function renderAccountRow(value, p, record) {
	return Ext.String.format('<div style="cursor:pointer">'+
		'<div style="font-weight:bold;font-size:130%">{0}'+
		'<div style="color:#777777;float:right;font-weight:normal;font-size:80%">'+
		'{3}&nbsp;|&nbsp;{2}</div></div>'+
		'<div style="color:#777777;font-style:italic;font-family:Georgia,Serif;'+
		'white-space:normal;">{1}</div>'+
		'</div>',
		value,record.data.description,record.data.balancefmt,record.data.currency.name);
}
